package juc.future;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;

/**
 * @author fangbin
 * @desc
 * @date 2020/6/30 7:59
 */
public class MultiFuture {

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        Callable callable   = ()->{
            Thread.sleep(2000);
            return Math.random()*1000;
        };

        Callable callable1 = new Callable() {
            @Override
            public Object call() throws Exception {
                return null;
            }
        };


        ExecutorService executorService = Executors.newFixedThreadPool(2);
        List<Future> futureList = new ArrayList<>();
        for(int i=0;i<10;i++){
            Future submit = executorService.submit(callable);
            futureList.add(submit);
        }

        for(int i=0;i<futureList.size();i++){
            System.out.println(futureList.get(i).get());
        }

    }
}
